'''
Created on 2009-11-4

@author: summit
'''

if __name__ == '__main__':
    from pyPdf import PdfFileWriter, PdfFileReader
    import os, sys
    sys.argv.append('C:/Pro ASP.NET 3.5 in C# 2008')
    if len(sys.argv)<2:
        sys.exit("Usage: pymerge.py file_path")
    output = PdfFileWriter()
    files = os.listdir(sys.argv[1])
    files.sort()
    for f in files:
        input1 = PdfFileReader(file(os.path.join(sys.argv[1], f), "rb"))
        for i in range(input1.getNumPages()):
            output.addPage(input1.getPage(i))
    outputStream = file(os.path.join(sys.argv[1], os.path.split(sys.argv[1])[-1]+".pdf"), "wb")
    output.write(outputStream)
    outputStream.close()



      
        
    